{extend name="layout/popup" /}

{block name="content"}
<input type="hidden" name="ajax" id="ajax" value="1">
<link rel="stylesheet" href="__ADMIN__/css/formSelects-v4.css"/>
<div class="popup-header">
    <h1>编辑用户信息</h1>
</div>
<div class="popup-body">
    <form id="form_data" class="layui-form" method="post" action="{:url('save')}">
        <input type="hidden" name="opmode" value="edit">
        <input type="hidden" name="id" id="id" value="{$vo.id}">
        <div class="layui-row">

            <div class="layui-col-xs11">
                <div class="layui-form-item">
                    <label class="layui-form-label required">活动标题：</label>
                    <div class="layui-input-block w19">
                        <input type="text" name="title" placeholder="" class="layui-input" check="required" info="活动标题" value="{$vo.title}" />
                    </div>
                </div>
            </div>

            <div class="layui-col-xs11">
                <div class="layui-form-item">
                    <label class="layui-form-label required">活动描述：</label>
                    <div class="layui-input-block w19">
                        <input type="text" name="desc" placeholder="" class="layui-input" check="required" info="活动描述" value="{$vo.desc}" />
                    </div>
                </div>
            </div>

            <div class="layui-col-xs11">
                <div class="layui-form-item">
                    <label class="layui-form-label required">活动详情：</label>
                    <div class="layui-input-block w19">
                        <textarea class="layui-textarea layui-hide" name="content" info="推荐词" id="layui-editor">{$vo.content}</textarea>
                    </div>
                </div>
            </div>

        </div>
    </form>
</div>
<div class="popup-footer">
    <a class="layui-btn layui-btn-primary" onclick="popup_close();">取消</a>
    <a class="layui-btn" onclick="save();">保存</a>
</div>
{/block}
{block name="script"}
<script>
    layui.use(['form', 'jquery', 'layedit'], function () {
        let $ = layui.jquery,
        form = layui.form,
        layedit = layui.layedit;

        var editIndex = layedit.build('layui-editor');

        var fn = {
            select_dept: function () {
                winopen("{:url('select_dept')}", 560, 470);
            },
            save: function () {
                // 同步富文本内容
                layedit.sync(editIndex);
                
                send_form("form_data", "{:url('save')}", function (ret) {
                    if (ret.code) {
                        layer.msg(ret.msg, {
                            time: 1200
                        }, function () {
                            parent.location.reload(true);
                            popup_close();
                        });
                    } else {
                        layer.msg(ret.msg);
                        return false;
                    }
                });
            }
        };
        win_exp(fn);

        form.render();

    });
</script>
{/block}
